<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="X-UA-Compatible" content="ie=edge" />
	<title>Document</title>
	<script type="text/javascript">
//构造函数模式 
//小明 今年18岁 性别男 有男朋友 男朋友会说话 说什么自己定
 function Xiaoming(name,age,sex,boyfriend){
 		this.name=name;
        this.age=age;
        this.sex=sex;
        this.boyfriend = boyfriend;
        this.boyfriendSay = function(){
            alert("我叫"+this.name+"，今年"+this.age+"，性别："+this.sex+"，我"+this.boyfriend+"，我想说")
        }
    }
    var obj=new Xiaoming("小明","18","男","有男朋友");
    obj.boyfriendSay();
//工厂模式
//造一辆车 出厂 （合格证/建议零售价/说明书）
function cart(certificate,price,ins){
        var car=new Object();
        car.certificate=certificate;
        car.price=price;
        car.ins=ins;
        car.show=function(){
            return this.certificate+this.price+this.ins
        }
        return car;
    }
    var car1=cart("合格证","130000万","擎天柱");
    var car2=cart("合格证","不要钱","汽车人变形");
    alert(car1.show())
    alert(car2.show())
	</script>
</head>
<body>
	
</body>
</html>